// 用户模块
let userList = [
    {id:1001,username:'jack',age:18},
    {id:1002,username:'rose',age:19},
]
module.exports = [
    //1. 用户列表接口
    {
        url:'/user/list',
        type:'get',
        response: config=>{
            return {
                resultCode:1,
                resultInfo:userList
            }
        }
    },
    // 2.用户删除接口
    {
        url:'/user/delete',
        type:'get',
        response:config=>{
            console.log('config ',config.query);
            let {id} = config.query
            let index = userList.findIndex(item=>item.id == id)
            userList.splice(index,1)
            return {
                resultCode:1,
                resultInfo:'删除成功'
            }
        }
    },
    // 3. 添加用户
    {
        url:'/user/add',
        type:'post',
        response:config=>{
            let {id,username,age} = config.body
            let user = {id,username,age}
            userList.push(user)
            return {
                resultCode:1,
                resultInfo:'添加成功'
            }
        }
    }
]